package io.gitee.chearnee.fw.datasecurity.core.util;

import io.gitee.chearnee.fw.datasecurity.core.exception.DataDesensitizationException;
import io.gitee.chearnee.fw.datasecurity.core.exception.DbCryptRuntimeException;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.slf4j.helpers.FormattingTuple;
import org.slf4j.helpers.MessageFormatter;

/**
 * @author cn
 * @version 1.0
 * @description
 * @date 11/10/2022 3:17 PM
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class DataSecurityAssertUtil {

    public static void desensitizationFail(String message, Object... args) {
        FormattingTuple formattingTuple = MessageFormatter.arrayFormat(message, args);
        throw new DataDesensitizationException(formattingTuple.getMessage(), formattingTuple.getThrowable());
    }

    public static void dbCryptFail(String message, Object... args) {
        FormattingTuple formattingTuple = MessageFormatter.arrayFormat(message, args);
        throw new DbCryptRuntimeException(formattingTuple.getMessage(), formattingTuple.getThrowable());
    }

}
